package com.wicket.okrcalc.common.exception;



import com.wicket.okrcalc.common.enums.ResponseStateEnum;
import lombok.Getter;


/**
 * @author ：CHS
 * @since 2023/02/18 13:16
 *
 *
 * @version 1.0
 */
public class BizException extends RuntimeException {
    @Getter
    private final String errorCode;
    @Getter
    private final boolean isErrLog;

    public BizException(String message, boolean errorLog) {
        super(message);
        this.errorCode = ResponseStateEnum.FAILURE.getCode();
        this.isErrLog = errorLog;
    }

    public BizException(String message, Throwable e, boolean errorLog) {
        super(message, e);
        this.isErrLog = errorLog;
        this.errorCode = ResponseStateEnum.FAILURE.getCode();
    }

    public BizException(String code, String message, boolean errorLog) {
        super(message);
        //强制转成-1，为了避免spring框架无法转换字母错误码的问题
        this.errorCode = "-1";
        this.isErrLog = errorLog;
    }

    public BizException(String code, String message, Throwable e, boolean errorLog) {
        super(message, e);
        this.errorCode = code;
        this.isErrLog = errorLog;
    }
}
